package com.eemint.controller;

import com.eemint.config.WebResult;
import com.eemint.entity.MailInfo;
import com.eemint.service.MailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;


/***
 *  Copyright (C), 2019,12, eemint
 *  File name and path : com.eemint.controller.MainController.java
 *  Author : Dallas,
 *  Version : 1.0,
 *  First complete date : 2019/12/24 11:46
 *  Description :          数据监控任务接口
 *  History:  nothing
 *
 ***/
@Slf4j
@RestController
//@RequestMapping("/eemint")
public class MainController {

    @Autowired
    private MailService mailService;

    /**
     * Function:  sendMail;
     * Author :  Dallas,
     * Version : 1.0,
     * First complete date : 2019/12/24 11:46;
     * Description :
     * History: nothing
     * Param and Description : 发送邮件
     *
     * @param invo Return:java.lang.Object
     **/
    @PostMapping("/mail/send")
    public Object sendMail(@RequestBody @Validated MailInfo invo) {

        //添加 发送邮件 到队列中
        mailService.addQueue(invo);
        Object res = WebResult.success("mail send success!");
        return res;
    }

}
